+Sun Mar 14 23:36:15 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkfilechooserdefault.c: Implement local_only by
+ filtering the shortcuts and bookmarks list by
+ gtk_file_system_path_to_filename (file_system, path) != NULL.
+ (#132894)
+
+ * gtk/gtkfilesystem.c (gtk_file_system_path_is_local): Add
+ a convenience function, may by interesting to push to the
+ file system vtable later for performance.
+
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+Sun Mar 14 23:36:15 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkfilechooserdefault.c: Implement local_only by
+ filtering the shortcuts and bookmarks list by
+ gtk_file_system_path_to_filename (file_system, path) != NULL.
+ (#132894)
+
+ * gtk/gtkfilesystem.c (gtk_file_system_path_is_local): Add
+ a convenience function, may by interesting to push to the
+ file system vtable later for performance.
+
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+Sun Mar 14 23:36:15 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkfilechooserdefault.c: Implement local_only by
+ filtering the shortcuts and bookmarks list by
+ gtk_file_system_path_to_filename (file_system, path) != NULL.
+ (#132894)
+
+ * gtk/gtkfilesystem.c (gtk_file_system_path_is_local): Add
+ a convenience function, may by interesting to push to the
+ file system vtable later for performance.
+
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+Sun Mar 14 23:36:15 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkfilechooserdefault.c: Implement local_only by
+ filtering the shortcuts and bookmarks list by
+ gtk_file_system_path_to_filename (file_system, path) != NULL.
+ (#132894)
+
+ * gtk/gtkfilesystem.c (gtk_file_system_path_is_local): Add
+ a convenience function, may by interesting to push to the
+ file system vtable later for performance.
+
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
+Sun Mar 14 23:36:15 2004 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkfilechooserdefault.c: Implement local_only by
+ filtering the shortcuts and bookmarks list by
+ gtk_file_system_path_to_filename (file_system, path) != NULL.
+ (#132894)
+
+ * gtk/gtkfilesystem.c (gtk_file_system_path_is_local): Add
+ a convenience function, may by interesting to push to the
+ file system vtable later for performance.
+
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
path = paths->data;
error = NULL;
+ if (impl->local_only &&
+ !gtk_file_system_path_is_local (impl->file_system, path))
+ continue;
+
/* NULL GError, but we don't really want to show error boxes here */
if (shortcuts_insert_path (impl, start_row + num_inserted, FALSE, NULL, path, NULL, TRUE, NULL))
num_inserted++;
GtkFileSystemVolume *volume;
volume = l->data;
+
+ if (impl->local_only)
+ {
+ GtkFilePath *base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
+ gboolean is_local = gtk_file_system_path_is_local (impl->file_system, base_path);
+ gtk_file_path_free (base_path);
+
+ if (!is_local)
+ continue;
+ }
+
shortcuts_insert_path (impl, start_row + n, TRUE, volume, NULL, NULL, FALSE, NULL);
n++;
}
impl->extra_widget = extra_widget;
}
+static void
+set_local_only (GtkFileChooserDefault *impl,
+ gboolean local_only)
+{
+ if (local_only != impl->local_only)
+ {
+ impl->local_only = local_only;
+
+ if (impl->shortcuts_model && impl->file_system)
+ {
+ shortcuts_add_volumes (impl);
+ shortcuts_add_bookmarks (impl);
+ }
+
+ if (local_only &&
+ !gtk_file_system_path_is_local (impl->file_system, impl->current_folder))
+ {
+ /* If we are pointing to a non-local folder, make an effort to change
+ * back to a local folder, but it's really up to the app to not cause
+ * such a situation, so we ignore errors.
+ */
+ const gchar *home = g_get_home_dir ();
+ GtkFilePath *home_path = gtk_file_system_filename_to_path (impl->file_system, home);
+
+ _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), home_path, NULL);
+
+ gtk_file_path_free (home_path);
+ }
+ }
+}
+
static void
volumes_changed_cb (GtkFileSystem *file_system,
GtkFileChooserDefault *impl)
set_current_filter (impl, g_value_get_object (value));
break;
case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
- impl->local_only = g_value_get_boolean (value);
+ set_local_only (impl, g_value_get_boolean (value));
break;
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
set_preview_widget (impl, g_value_get_object (value));
if (!check_is_folder (impl->file_system, path, error))
return FALSE;
+ if (impl->local_only &&
+ !gtk_file_system_path_is_local (impl->file_system, path))
+ {
+ g_set_error (error,
+ GTK_FILE_SYSTEM_ERROR,
+ GTK_FILE_SYSTEM_ERROR_FAILED,
+ _("Can't change to folder because it isn't local"));
+
+ return FALSE;
+ }
+
if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, error))
return FALSE;
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->filename_to_path (file_system, filename);
}
+/**
+ * gtk_file_system_path_is_local:
+ * @filesystem: a #GtkFileSystem
+ * @path: A #GtkFilePath from that filesystem
+ *
+ * Checks whether a #GtkFilePath is local; that is whether
+ * gtk_file_system_path_to_filename would return non-%NULL.
+ *
+ * Return value: %TRUE if the path is loca
+ **/
+gboolean
+gtk_file_system_path_is_local (GtkFileSystem *file_system,
+ const GtkFilePath *path)
+{
+ gchar *filename;
+ gboolean result;
+
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ filename = gtk_file_system_path_to_filename (file_system, path);
+ result = filename != NULL;
+ g_free (filename);
+
+ return result;
+}
+
GdkPixbuf *
gtk_file_system_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
const gchar *filename);
+gboolean gtk_file_system_path_is_local (GtkFileSystem *filesystem,
+ const GtkFilePath *path);
+
GdkPixbuf *gtk_file_system_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkWidget *widget,